﻿<%@ Page Title="" Language="C#" MasterPageFile="~/VukhoasAdmin/admin.Master" AutoEventWireup="true"  Debug="true" CodeBehind="ListProduct.aspx.cs" Inherits="vukhoas.VukhoasAdmin.ListProduct" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<title>Danh sách sản phẩm</title>
<script type="text/javascript">
    function del(ee) {
        if(confirm("Bạn có chắc chắn muốn xóa ?"))
        {
        $.ajax({
            type: "POST",
            url: "ListProduct.aspx/del",
            contentType: "application/json; charset=utf-8",
            data: "{'id':'"+ee+"'}",
            dataType: 'json',
            success: ok
        });
        }else{
            return;
        }
    };

    function ok(data) {
        alert(data.d);
        location.reload(true);
    };      
   
</script>
<title>Danh sách sản phẩm</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="admin_product">
<form id="Form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"  EnablePageMethods="true" />

<table>
    <tr class="header">
        <td>
            
        </td>
        <td>
            <label>Tên sản phẩm</label>
        </td>
        <td>
            <label>Giá</label>
        </td>
        <td>
            <label>Loại sản phẩm</label>
        </td>
        <td>
            <label>Nhà sản xuất</label>
        </td>        
        <td>
            <label>Ngày tạo</label>
        </td>
        <td>
            
        </td>
    </tr>


<%if (lstProduct().Count != 0)
  {
      foreach (vukhoas.src.POJO.Product pro in lstProduct())
      {
          int id = pro.Id;
                %>
      <tr>
      <td>
            <img src="<%=vukhoas.src.ListImage.GetImagesPath(pro.Image)[0] %>" alt="" />
      </td>
      <td>
            <label><%=pro.Name%></label>
      </td>
      <td>
            <label><%=pro.Price%> đ</label>    
      </td>
      <td>
            <label><%=pro.CategoryName %></label>
      </td>
      <td>
            <label><%=pro.ManufactureName %></label>
      </td>
       <td>
            <label><%=pro.CreatedDate %></label>
      </td>
      <td>
          <a href="NewProduct.aspx" ><img src="/image/icon/add24.png" 
              style="width:24px;height:24px;"/></a>              
          <a href="EditProduct.aspx?id=<%=pro.Id%>" ><img src="/image/icon/edit24.png" 
              style="width:24px;height:24px;"/></a>              
          <a onclick="del(<%=pro.Id%>)" ><img src="/image/icon/exit24.png" 
          style="width:24px;height:24px;"/></a>
      </td>
      </tr>
<%
      }
  }
  else
  {%>
  <tr>
  <td colspan="6">
  <label>Không có sản phẩm nào phù hợp</label>
  </td>
  </tr>
  
  <%} %>
  </table>
  </form>
  </div>
</asp:Content>
